﻿using System;

using ExtensibleEventViewer.Console.EventArguments;


namespace ExtensibleEventViewer.Console.Forms
{
	public partial class AddComputerWnd : FormBase
	{
		public Action<string> AddComputer;

		public AddComputerWnd()
		{
			InitializeComponent();

			addComputerControl.AddComputer += OnComputerAdded;
			addComputerControl.CancelAdding += OnCancelAdding;
		}

		private void OnComputerAdded(object sender, ComputerEventArgs eventArgs)
		{
			if (AddComputer != null)
			{
				AddComputer(eventArgs.ComputerName);
			}

			Close();
		}

		private void OnCancelAdding(object sender, EventArgs args)
		{
			Close();
		}
	}
}
